package com.sweet.multipledatasources;

import com.zaxxer.hikari.HikariDataSource;
import io.vertx.core.Vertx;
import io.vertx.jdbcclient.JDBCPool;
import io.vertx.sqlclient.Row;

public class OracleDemo {
  public static void main(String[] args) throws InterruptedException {
    Vertx vertx = Vertx.vertx();
    HikariDataSource dataSource = new HikariDataSource();
    dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
    dataSource.setJdbcUrl("jdbc:oracle:thin:@localhost:1521:FREE");
    dataSource.setUsername("system");
    dataSource.setPassword("123456");
    dataSource.addDataSourceProperty("currentSchema", "SYSTEM");
    JDBCPool pool = JDBCPool.pool(vertx, dataSource);
    System.out.println(pool);
    pool.preparedQuery("SELECT * FROM SYSTEM.\"t_User\"").execute().onSuccess(res -> {
      System.out.println(res.size());
      for (Row row : res.value()) {
        System.out.println(row.toJson());
      }
    }).onFailure(err -> {
      err.printStackTrace();
    });
    Thread.sleep(50000000L);
  }
}
